class Solution {
public:
    bool lemonadeChange(vector<int>& bills) {
        int five = 0;
        int ten = 0;
        int twenty = 0;
        for (int i = 0; i < bills.size(); i++)
        {
            if (bills[i] == 5)
            {
                five++;
            }
            else if (bills[i] == 10)
            {
                if (five >= 1)
                {
                    five -= 1;
                    ten++;
                }
                else
                {
                    return false;

                }
            }
            else
            {
                if (ten >= 1 && five >= 1)
                {
                    ten -= 1;
                    five -= 1;

                }
                else if (five >= 3)
                {
                    five -= 3;
                }
                else
                {
                    return false;
                }

            }



        }
        return true;

    }
}; class Solution {
public:
    int halveArray(vector<int>& nums) {
        double sum = 0;
        for (auto e : nums)
        {
            sum += e;
        }
        double target = sum / 2;
        priority_queue<double>st;
        for (auto e : nums)
        {
            st.push(e);
        }
        double count = 0;
        while (sum > target)
        {

            double ret = st.top();
            sum -= ret;
            st.pop();
            sum += ret / 2;
            st.push(ret / 2);
            count++;
        }
        return count;

    }
};